{extend name="/base"}
{block name="css"}
   <link rel="stylesheet" href="__ADMIN__/css/pearForm.css" />
   <style>
    .pear-container{background-color:white;}
    body{margin: 10px;}
   </style>
{/block}
{block name="body"}
    <form class="layui-form  edit-form" action="" lay-filter="component-form-element">
        <div class="layui-form-item">
            <label for="" class="layui-form-label">父级</label>
            <div class="layui-input-block">
                <select name="pid" lay-verify="requried">
                    <option value="0">顶级</option>
                    {foreach $permissions as $k1=>$p1}
                        <option value="{$p1.id}" {if isset($model) && $model->pid==$p1['id']} selected {/if} >{$p1.title}</option>
                        {if isset($p1['children']) && !empty($p1['children']) }
                            {foreach $p1['children'] as $k2=>$p2}
                                <option value="{$p2.id}" {if isset($model) && $model->pid==$p2['id']} selected {/if} >&nbsp;&nbsp;&nbsp;┗━━{$p2.title}</option>
                            {/foreach}
                        {/if}
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                所属多级
            </label>
            <div class="layui-input-block">
                <select lay-verify="required" name="mid">
                    {foreach $multi as $k=>$v}
                    <option value="{$k}">
                        {$v}
                    </option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="" class="layui-form-label">权限名称</label>
            <div class="layui-input-block">
                <input type="text" maxlength="16" name="title" value="{$model->title??''}" lay-verify="required" placeholder="请输入权限名称" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <label for="" class="layui-form-label">地址</label>
            <div class="layui-input-block">
                <input type="text" name="href" value="{$model->href??''}" lay-verify="required" placeholder="请输入地址" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <label for="" class="layui-form-label">图标</label>
            <div class="layui-input-block">
                    <div class="layui-input-inline">
                    <input type="text" id="iconPicker2" name="icon" value="layui-icon-face-smile-fine" lay-filter="iconPicker2" class="hide">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限类型：</label>
            <div class="layui-input-block">
            {if empty($model->type)}
              <input type="radio" name="type" value="0" title="目录" checked>
              <input type="radio" name="type" value="1" title="菜单">
            {else}
              <input type="radio" name="type" value="0" title="目录" {if condition="$model->type eq 0"} checked {/if}>
              <input type="radio" name="type" value="1" title="菜单" {if condition="$model->type eq 1"} checked {/if}>
            {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label for="" class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" name="sort" value="{$model->sort??10}" lay-verify="required" placeholder="排序权重" class="layui-input" >
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="apiform">提 交</button>
            </div>
        </div>
    </form>
    {/block}
    {block name="js"}
    <script src="/static/admin/layui/layui.js"></script>
    <script>
        layui.use(['jquery','form','layer','iconPicker'],function () {
               var iconPicker= layui.iconPicker;
               var $=layui.jquery;
               var form=layui.form;
               var layer=layui.layer;
               iconPicker.render({
                elem: '#iconPicker2',
                type: 'fontClass',
                search: true,
                // 是否开启分页
                page: true,
                limit: 12,
                click: function (data) {
                },
                success: function(d) {
                }
            });
           })
       </script>
    {/block}